#猜一猜数字

import random
i=0
number=random.randint(1,50)
while i <=6:
    i+=1
    shuzi=int(input('请输入1到50的整数'))
    if shuzi==number:
        print('猜对了')
        break
    elif shuzi > number:
        print('输入的数字太大了')
    else:
        print('输入的数字太小了')
print('系统生成随机数为%d' %number)



#元音查询

vowels={'a','e','i','o','u'}
word=input('请提供一个英文单词来查询')
found={}
found['a']=0
found['e']=0
found['i']=0
found['o']=0
found['u']=0
for letter in word:
    if letter in vowels:
        found[letter]+=1
for k,v in sorted(found.items()):
    print(k,'was found',v,'times')



#查询元音改进，去除found里没有的元音显示，只显示found所有的元音次数。

vowels={'a','e','i','o','u'}
word=input('请提供一个英文单词来查询')
found={}
for letter in word:
    if letter in vowels:
        found.setdefault(letter,0)
        found[letter]+=1
for k,v in sorted(found.items()):
    print(k,'was found',v,'times')

# 创建名为found的集合，用来放置vowels集合和word集合共同的元音元素。
vowels={'a','e','i','o','u'}
word=input('请提供一个英文单词来查询')
found=vowels.intersection(set(word))
for vowel in found:
    print(vowel)


# azure人脸，提取字典值
import requests
import json
face_api_url = 'https://faceused.cognitiveservices.azure.cn/face/v1.0/detect'
image_url ='https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1603966302895&di=712844c28baad55345e00c39dee79dae&imgtype=0&src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fimages%2F20180211%2F0ab39f68d5034c8a8b1cbf883b87e055.jpeg'
headers ={'Ocp-Apim-Subscription-Key': 'ee69143f1b16449481a58bc222f73eb2'}
params ={ 
    'returnFaceId': 'true',
    'returnFaceLandmarks': 'false',
    'returnFaceAttributes':'age,gender,smile,facialHair,glasses,emotion,hair,makeup,occlusion,accessories,blur,exposure,noise'}
response = requests.post(face_api_url, params=params,headers=headers, json={"url": image_url})
results=response.json()
results
#结果

```
[{'faceId': 'a3db6629-5c07-4224-90c4-f7673676eee4',
  'faceRectangle': {'top': 109, 'left': 51, 'width': 129, 'height': 129},
  'faceAttributes': {'smile': 0.005,
   'gender': 'male',
   'age': 63.0,
   'facialHair': {'moustache': 0.1, 'beard': 0.1, 'sideburns': 0.1},
   'glasses': 'NoGlasses',
   'emotion': {'anger': 0.0,
    'contempt': 0.0,
    'disgust': 0.0,
    'fear': 0.0,
    'happiness': 0.005,
    'neutral': 0.994,
    'sadness': 0.0,
    'surprise': 0.0},
   'blur': {'blurLevel': 'low', 'value': 0.22},
   'exposure': {'exposureLevel': 'goodExposure', 'value': 0.68},
   'noise': {'noiseLevel': 'low', 'value': 0.21},
   'makeup': {'eyeMakeup': False, 'lipMakeup': False},
   'accessories': [],
   'occlusion': {'foreheadOccluded': False,
    'eyeOccluded': False,
    'mouthOccluded': False},
   'hair': {'bald': 0.02,
    'invisible': False,
    'hairColor': [{'color': 'blond', 'confidence': 0.99},
     {'color': 'gray', 'confidence': 0.99},
     {'color': 'other', 'confidence': 0.44},
     {'color': 'brown', 'confidence': 0.08},
     {'color': 'red', 'confidence': 0.07},
     {'color': 'black', 'confidence': 0.02}]}}},
 {'faceId': '2c25b9f6-b587-4c01-b50f-8c4a968701f0',
  'faceRectangle': {'top': 92, 'left': 561, 'width': 114, 'height': 114},
  'faceAttributes': {'smile': 1.0,
   'gender': 'male',
   'age': 40.0,
   'facialHair': {'moustache': 0.1, 'beard': 0.1, 'sideburns': 0.1},
   'glasses': 'NoGlasses',
   'emotion': {'anger': 0.0,
    'contempt': 0.0,
    'disgust': 0.0,
    'fear': 0.0,
    'happiness': 1.0,
    'neutral': 0.0,
    'sadness': 0.0,
    'surprise': 0.0},
   'blur': {'blurLevel': 'low', 'value': 0.1},
   'exposure': {'exposureLevel': 'goodExposure', 'value': 0.63},
   'noise': {'noiseLevel': 'low', 'value': 0.04},
   'makeup': {'eyeMakeup': False, 'lipMakeup': False},
   'accessories': [],
   'occlusion': {'foreheadOccluded': False,
    'eyeOccluded': False,
    'mouthOccluded': False},
   'hair': {'bald': 0.04,
    'invisible': False,
    'hairColor': [{'color': 'black', 'confidence': 0.98},
     {'color': 'brown', 'confidence': 0.96},
     {'color': 'gray', 'confidence': 0.56},
     {'color': 'other', 'confidence': 0.15},
     {'color': 'blond', 'confidence': 0.11},
     {'color': 'red', 'confidence': 0.03}]}}},
 {'faceId': '427759e0-7393-4a98-af5c-9be4cf91192e',
  'faceRectangle': {'top': 63, 'left': 298, 'width': 104, 'height': 104},
  'faceAttributes': {'smile': 0.869,
   'gender': 'male',
   'age': 55.0,
   'facialHair': {'moustache': 0.1, 'beard': 0.1, 'sideburns': 0.1},
   'glasses': 'NoGlasses',
   'emotion': {'anger': 0.0,
    'contempt': 0.001,
    'disgust': 0.0,
    'fear': 0.0,
    'happiness': 0.869,
    'neutral': 0.13,
    'sadness': 0.0,
    'surprise': 0.0},
   'blur': {'blurLevel': 'medium', 'value': 0.28},
   'exposure': {'exposureLevel': 'goodExposure', 'value': 0.66},
   'noise': {'noiseLevel': 'low', 'value': 0.0},
   'makeup': {'eyeMakeup': False, 'lipMakeup': False},
   'accessories': [],
   'occlusion': {'foreheadOccluded': False,
    'eyeOccluded': False,
    'mouthOccluded': False},
   'hair': {'bald': 0.96, 'invisible': False, 'hairColor': []}}}]

   ```

smile1=results[0]['faceAttributes']['smile']
gender1=results[0]['faceAttributes']['gender']
age1=results[0]['faceAttributes']['age']
glasses1=results[0]['faceAttributes']['glasses']
haircolor1=results[0]['faceAttributes']['hair']['hairColor']
face1={}
face1['smile']=smile1
face1['gender']=gender1
face1['age']=age1
face1['glasses']=glasses1
face1['haircolor']=haircolor1


smile2=results[1]['faceAttributes']['smile']
gender2=results[1]['faceAttributes']['gender']
age2=results[1]['faceAttributes']['age']
glasses2=results[1]['faceAttributes']['glasses']
haircolor2=results[1]['faceAttributes']['hair']['hairColor']
face2={}
face2['smile']=smile2
face2['gender']=gender2
face2['age']=age2
face2['glasses']=glasses2
face2['haircolor']=haircolor2


smile3=results[2]['faceAttributes']['smile']
gender3=results[2]['faceAttributes']['gender']
age3=results[2]['faceAttributes']['age']
glasses3=results[2]['faceAttributes']['glasses']
haircolor3=results[2]['faceAttributes']['hair']['hairColor']
face3={}
face3['smile']=smile3
face3['gender']=gender3
face3['age']=age3
face3['glasses']=glasses3
face3['haircolor']=haircolor3


